import React, { useContext, useState, createContext } from 'react'

export const Context = createContext()

export default function About4() {
    const [state] = useState(100)
    return (
        <div>
            <h4>
                我是父 -- { state }
            </h4>
            <Context.Provider value={state}>
                <Son/>
            </Context.Provider>
        </div>
    )
}


function Son() {
    const text = useContext(Context)
    return (
        <div>
            <h4>
                我是子 -- { text }
            </h4>
        </div>
    )
}

